package com.xcity.record;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

import com.xcity.merge.MergeUtil;

public class GuildMember extends BaseRecord {

	public static String SQL_PARA = "id, guildid, duty, createTime, lastGetDay, memData";
	public static String COUNT_SQL = "select count(id) from guildmember {0}";
	public static String SELECT_LIMIT = "select * from guildmember {2} limit {0},{1}";
	public static String CONDITION = "where guildmember.id not IN (SELECT player.id FROM player WHERE player.vipLvl = {0} AND player.`level` < {1} AND player.lastLoginTime < \"{2}\")";
	
	protected long id;
	protected long guildid;
	protected int duty;
	protected Date createTime;
	protected int lastGetDay;
	protected String memData;
	
	@Override
	public void load(ResultSet rs) throws SQLException {
		this.id = rs.getLong(1);
		this.guildid = rs.getLong(2);
		this.duty = rs.getInt(3);
		this.createTime = rs.getTimestamp(4);
		this.lastGetDay = rs.getInt(5);
		this.memData = rs.getString(6);
	}

	@Override
	public String getColumnNames() {
		return SQL_PARA;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(MergeUtil.toSqlString(id));
		sb.append(", ");
		sb.append(MergeUtil.toSqlString(guildid));
		sb.append(", ");
		sb.append(MergeUtil.toSqlString(duty));
		sb.append(", ");
		sb.append(MergeUtil.toDateString(createTime));
		sb.append(", ");
		sb.append(MergeUtil.toSqlString(lastGetDay));
		sb.append(", ");
		sb.append(MergeUtil.toSqlString(memData));
		return sb.toString();
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getGuildid() {
		return guildid;
	}

	public void setGuildid(long guildid) {
		this.guildid = guildid;
	}

	public int getDuty() {
		return duty;
	}

	public void setDuty(int duty) {
		this.duty = duty;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public int getLastGetDay() {
		return lastGetDay;
	}

	public void setLastGetDay(int lastGetDay) {
		this.lastGetDay = lastGetDay;
	}

	public String getMemData() {
		return memData;
	}

	public void setMemData(String memData) {
		this.memData = memData;
	}
}
